package ajax17;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.mysql.jdbc.Driver;

public class DBtest {

	public static void main(String[] args) {
		PreparedStatement pstmt = null;
		Connection conn = null;
		
		
		try {
			// 1
			DriverManager.registerDriver(new Driver());
			// 2
			conn = DriverManager.getConnection(
			"jdbc:mysql://j.snpy.org/j102", "jstu", "abc123");
			String sql = "update users set nickname=? where id=?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setString(1, "userid");
			pstmt.setString(2, "stu17");
			int row_cnt = pstmt.executeUpdate();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}finally {
			try {
				if (conn != null && pstmt != null) {
					pstmt.close();
					conn.close();
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
